using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.HtmlControls;
using ThoughtWorks.CruiseControl.Remote;

namespace CruiseControlStatus
{
    public class ProjectHtmlButton : HtmlButton
    {
        private string _ProjectName;
        ICruiseManager _CruiseManager;

        public string ProjectName
        {
            get { return _ProjectName; }
        }

        public ProjectHtmlButton(ICruiseManager cruiseMgr, string projName)
        {
            _ProjectName = projName;
            InnerText="Force";
            _CruiseManager = cruiseMgr;
            ServerClick += new EventHandler(_ForceButton_click);
        }

        public void _ForceButton_click(object sender, EventArgs e)
        {
            if (sender is ProjectHtmlButton)
            {
                ProjectHtmlButton but = sender as ProjectHtmlButton;
                try
                {
                    _CruiseManager.ForceBuild(but.ProjectName);
                }
                catch
                {

                }

            }
        }


    }
}
